<%@page import="dto.companyFormDTO"%>
<%@page import="vo.companyFormVO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/company_form.css"/>
<script src = '../js/form.js'></script>
<title>Insert title here</title>
</head>
<body>
<% request.setCharacterEncoding("UTF-8"); 
	int form_number =  Integer.parseInt(request.getParameter("form_number"));

	companyFormDTO cdto = new companyFormDTO();
	
	companyFormVO cvo = cdto.form_view_info(form_number);
	
	String m_id = (String) session.getAttribute("sessionMid");
	
	long my_number =  cdto.find_my_number(m_id);
	long check_number = 0;
	boolean check_on = false;
	
	switch(cvo.getC_draft_now_state()){
	case 1:
		check_number = cvo.getC_draft_approbator_1();
		break;
	case 2:
		check_number = cvo.getC_draft_approbator_2();
		break;
	case 3:
		check_number = cvo.getC_draft_approbator_3();
		break;
	case 4:
		check_number = cvo.getC_draft_approbator_4();
		break;
	case 5:
		check_number = cvo.getC_draft_approbator_5();
		break;
	default : 
		check_number = 0;
		break;
	}
	System.out.print("my_number : " + my_number);
	System.out.print("cvo.getE_number() : " + cvo.getE_number());
	System.out.print("cvo.getC_draft_now_state() : " + cvo.getC_draft_now_state());
	if(my_number == check_number){
		check_on = true;
	}
	
	int length_is = 0;
	length_is = String.valueOf(cvo.getForm_number()).length();
%>


	<div id="top">
	</div>
	<div id="payment" align="center">		
	<h1>결제보고서</h1>
	<form name="frm" method="post">
	
	<input type='hidden' name="form_number"  value="<%=cvo.getForm_number()%>" />
	
	<input type='hidden' name="m_id"  value="<%=cvo.getM_id()%>" />
	
	<input type='hidden' name="c_form_number"  value="<%=cvo.getC_form_number()%>-" />
	
	<input type='hidden' name="c_draft_date" value="<%=cvo.getC_draft_date()%>" />
	
	<input type='hidden' name="e_name" value="<%=cvo.getE_name()%>"/>
	<input type='hidden' name="e_number" value="<%=cvo.getE_number()%>"/>
	<input type='hidden' name="e_position" value="<%=cvo.getE_position()%>"/>
	<input type='hidden' name="d_tname" value="<%=cvo.getD_tname()%>"/>
	
	<input type='hidden' name="c_draft_approbator_1" value="<%=cvo.getC_draft_approbator_1()%>"/>
	<input type='hidden' name="c_draft_approbator_2" value="<%=cvo.getC_draft_approbator_2()%>"/>
	<input type='hidden' name="c_draft_approbator_3" value="<%=cvo.getC_draft_approbator_3()%>"/>
	<input type='hidden' name="c_draft_approbator_4" value="<%=cvo.getC_draft_approbator_4()%>"/>
	<input type='hidden' name="c_draft_approbator_5" value="<%=cvo.getC_draft_approbator_5()%>"/>
	
	
	
	<table class="table_head" width="650" align="center" border="0" cellpadding="4" cellspacing="0" bordercolor="#000" >
		<tr>
			<td>
				<table class="table_item1" cellSpacing=0 cellPadding=0 width="100%" border=1>
					<tbody>
						<TR>
							<TD class="form_item1" width= 15%> &nbsp; 폼의번호</TD>
							<TD class="form_item2" width= 35%> &nbsp;<%=cvo.getC_form_number() %>-
							<%for(int j = length_is; j< 5; j++){%>0<%}out.print(cvo.getForm_number());%></TD>
							<TD class="form_item1" width= 15%> &nbsp; 신청구분</TD>
							<TD class="form_item2" width= 35%>&nbsp; 
							<%switch(cvo.getC_form_type()){
							case 1:
								out.print("결제 요청");
								break;
							case 2:
								out.print("업무 이관");
								break;
							case 3:
								out.print("기획서");
								break;
							case 4:
								out.print("구매 이력서");
								break;
							default:
								out.print("오류");
								break;
							}
							%>
									</TD>
						</TR>
				
						<TR>
							<TD class="form_item1">&nbsp; 기안일자 </TD>
							<TD class="form_item2">&nbsp; <%=cvo.getC_draft_date() %> </TD>
							<TD class="form_item1">&nbsp; 기안부서 </TD>
							<TD class="form_item2">&nbsp;<%=cvo.getD_tname() %></TD>
						</TR>
				
						<TR>
							<TD class="form_item1">&nbsp; 기안자 </TD>
							<TD class="form_item2">&nbsp; <%=cvo.getE_name() %> </TD>
							<TD class="form_item1">&nbsp; 업무기간 </TD>
							<TD class="form_item2">&nbsp;
								<%=cvo.getC_draft_start_date()%> &nbsp;~<%=cvo.getC_draft_end_date()%> &nbsp;
							</TD>
						</TR>
			
						<TR>
							<TD class="form_item1">&nbsp; 시 행 자 </TD>
							<TD class="form_item1" colSpan=3><%=cvo.getE_name() %> </TD>
						</TR>
						
						
						<TR>
							<TD class="form_item1">&nbsp; 결 &nbsp; &nbsp; 재  </TD>
							<TD class="form_item6" colSpan=3>
								<span id='approval_line_html'>
									<table width='100%' height='100'>
									<tr height='20px'>
										<td width=16% align='center' style='border-right:0; border-bottom:1px solid #d5d5d5; text-align:center'	>&nbsp;
										<% out.print(cdto.user_name(cvo.getC_draft_approbator_1())); %></td>
										
										<td width=16% class="lect" >&nbsp; 
										<% out.print(cdto.user_name(cvo.getC_draft_approbator_2())); %></td>
										
										<td width=16% class="lect" >&nbsp; 
										<% out.print(cdto.user_name(cvo.getC_draft_approbator_3())); %></td>
										
										<td width=16% class="lect"  >&nbsp; 
										<% out.print(cdto.user_name(cvo.getC_draft_approbator_4())); %></td>
										
										<td width=16% class="lect"  >&nbsp; 
										<% out.print(cdto.user_name(cvo.getC_draft_approbator_5())); %></td>
									</tr>
									<tr height='94px'>
										<%for(int i = 1; i <= 5; i++){ %>
										<%if(i == 1){ %>
											<td align='center' valign='top' style='border-right:0; border-bottom:0;'>
										<%} else{ %>
											<td class="lect2" align='center' valign='top'>
										<%} %>
										
										<%if(check_on && cvo.getC_draft_now_state() == i){ %>&nbsp;
										<input type="button" value="승인합니다." onclick="finish(2)"/>
										<% } else if(cvo.getC_draft_now_state() <= i){ %>&nbsp; <%} else{%>
										승인 되었습니다.
										<%} %>
										</td>
										<%} %>
									</tr>
									</table>
								</span> 
							</TD>
						</TR>
						<TR>
							<TD class="form_item1">&nbsp; 제 &nbsp; &nbsp; 목 </TD>
							<TD class="form_item1" colSpan=3>&nbsp;
								<input type="text" name="c_draft_title" class="title" readonly="readonly"  value="<%=cvo.getC_draft_title() %>" maxlength="100"/>
							</TD>
						</TR>
						<TR>
							<TD class="form_item1">&nbsp; 내 &nbsp; &nbsp; 용 </TD>
							<TD class="form_item1" colSpan=3>&nbsp;
								<textarea name="c_draft_context" class="contents" readonly="readonly" ><%=cvo.getC_draft_context()%></textarea>
							</TD>
			
						</TR>
					</tbody>
				</table>
			</td>
		</tr>
	</table>	
	<%if(check_on){ %>
		<input type="button"  value="수정 요청"  onclick="finish(3)">
	<%} %>
	<%if(cvo.getC_draft_now_state() == 0 && my_number == cvo.getE_number()){ %>
		<input type="button"  value="수정 하기"  onclick="rollback()">
	<%} %>
	</form>
</div>
</body>
</html>